package com.zzdx.deployment.web.controller.file;

import com.zzdx.deployment.system.service.IFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Description 文件操作
 * @Author Mason
 * @Date 2018/12/25
 **/
@Controller
@RequestMapping("/file")
public class FileController {

    @Autowired
    private IFileService fileService;

    /**
     * 下载文件接口
     *
     * @param productResourceId 产品资源ID
     * @param response
     */
    @RequestMapping("/download")
    public void downloadFile(String productResourceId, HttpServletResponse response) {
        // 下载
        try {
            fileService.download(productResourceId,response);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    /**
     * 下载配置文件
     *
     * @param prjvConfigId 项目版本配置ID
     * @param response
     */
    @RequestMapping("/download_prop_file")
    public void downloadPropFile(String prjvConfigId, HttpServletResponse response) {
        fileService.downloadPropFile(prjvConfigId,response);
    }
}
